<?php
//namespace escouting\group_calendar\ui;

class Calendar_Display_Controller {
	public function __construct() {
		add_filter('the_content', array( &$this, 'page_route' ), 100);
	}
	
	public function page_route ( $content ) {
		global $post;
		
		if ( $post->ID == get_option( 'slog_calendar_page_id' ) ) {
			$curr_week = new Week();
			$display = Calendar_Display_Factory::get_display ( $curr_week );
			$content = $display->get_display_content();
		}
		return $content;
	}
}

class Calendar_Display_Factory {
	static function get_display ( $calendar_item ) {
		if ( $calendar_item instanceof Week )
			return new Week_Display( $calendar_item );
	}
}

abstract class Calendar_Display {
	abstract public function get_display_content ();
}

class Week_Display extends Calendar_Display {
	public function __construct ( Week $week ) {
		$this->display_week = $week;
	}
	
	private $display_week;
	
	public function get_display_content () {
		$dow = $this->display_week->days_of_week;
		
		$content = "<div>" . $this->display_week;
		$content .= "<ul>";
		for ($i = 0; $i < 7; $i++ ) {
			$curr_day = $dow[$i];
			$content .= "<li>" . $curr_day->get_day_of_week() . ", " . $curr_day->get_day_of_month() . "</li>";
		}
		$content .= "</ul>";
		$content .= "</div>";
		return $content;
	}
}